package uit.edu.vn.Activity;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TabHost;

public class MainActivity extends TabActivity {
	
	private final int menu_Logout=0;
	/** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //xu ly tab host
        // lay drawable
        Resources res = getResources(); 
        TabHost tabHost= getTabHost();
        TabHost.TabSpec spec;
        // Tạo intent và gọi các class tiep theo
        Intent i;
        //goi BackupActivity.class
        i= new Intent().setClass(this, BackupActivity.class);
        spec= tabHost.newTabSpec("").setIndicator("Sao Lưu",res.getDrawable(R.drawable.tab_backup_selector)).setContent(i);
        tabHost.addTab(spec);
        // goi RestoreActivity.class
        i= new Intent().setClass(this, RestoreActivity.class);
        spec= tabHost.newTabSpec("PHUCHOI").setIndicator("Phục Hồi",res.getDrawable(R.drawable.tab_restore_selector)).setContent(i);
        tabHost.addTab(spec);
        //goi InfoActivity.class
        i= new Intent().setClass(this, InfoActivity.class);
        spec= tabHost.newTabSpec("THONGTIN").setIndicator("Thông Tin",res.getDrawable(R.drawable.tab_infor_selector)).setContent(i);
        tabHost.addTab(spec);
        tabHost.setCurrentTab(0);        
    }
    //xu lý menu
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	// TODO Auto-generated method stub
    	//return super.onCreateOptionsMenu(menu);
    	 menu.add(0, menu_Logout, 0,"Đăng Xuất").setIcon(R.drawable.ic_error);
		return true;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	// TODO Auto-generated method stub
    	finish();
    	return true;
    }
}